<?php

if (!defined('IN_ADMIN')) {
    exit('Access Denied');
}

$mpurl = 'admin.php?ac=recomment';
$list = array();
if($_GET['op'] == 'addUserToRecomment') {
	$param	            =   $_GET;
	$param['uid']       =   trim($param['uid'],',');
	$param['do']		=	'addUserToRecomment';
	$param['format']	=	'json';
	
	$uidStrings =    trim($param['uid'], ',');
	$uidsArr    =    explode(',',$uidStrings);
	
	$content  =  get_api_content($_SC ['apiurl'], $param);
	$content  =  json_decode($content);
	
	if ($content->resultData > 0) {
		$msg = "操作成功!";
		cpmessage($msg);
	}
	$msg = "操作失败，请重试一次!";
	if ($content->errorNo) {
		$msg .= "errorNo:" . $content->errorNo;
	}
	cpmessage($msg);
}elseif($_GET['op'] == 'delUserFromRecomment') {
	$param	            =   $_GET;
	$param['do']		=	'delUserFromRecomment';
	$param['format']	=	'json';
	
	$content  =  get_api_content($_SC ['apiurl'], $param);
	$content  =  json_decode($content);
	
	$data = array(
	        'uid'    =>    $_GET['uid'],
	        'status' =>    3,
	        'do'     =>    'ability',
	        'action' =>    'setAbility',
	        'format' =>    'json'
	);
	$content = get_api_content($_SC ['apiurl'], $data);
	$content  =  json_decode($content);
	
	if ($content->resultData == 1) {
		$msg = "操作成功!";
		cpmessage($msg);
	}
	$msg = "操作失败，请重试一次!";
	if ($content->errorNo) {
		$msg .= "errorNo:" . $content->errorNo;
	}
	cpmessage($msg);
}else{
    if ($_GET['query'] == 1 )
    {
        $param	=  $_GET;
    }
    
    $param['uid']       =   $_SESSION['user']['adminUid'];
    $param['do']		=	'getRecommentList';
    $param['format']	=	'json';
    $start   			=   intval($_GET ['start']) > 0 ? intval($_GET ['start']) : 0;
    $perpage 			=   intval($_GET ['perpage']) > 0 ? intval($_GET ['perpage']) : 20;
    $param['start']		=	$start;
    $param['perpage']	=	$perpage;
    $param['orderby']   =   strval($_GET['orderby']) ? strval($_GET['orderby']) : 'la_act';
    $param['ordersc']   =   strval($_GET['ordersc']) ? strval($_GET['ordersc']) : 'desc';
    $page    =    intval($_GET['page']) > 0 ? intval($_GET['page']) : 0 ;
    if ($page){
        $start             =    ($page-1)*$perpage;
        $param['start']	   =	$start;
    }
    $currtenPage        =   ceil($start/$perpage) + 1;
    
    $content  			=  	get_api_content($_SC ['apiurl'], $param);
    $content  			=  	json_decode($content);
    $recommentList 		=  	object_to_array($content->resultData);
    $urls      			=  	$recommentList['urls'];
    $result             =   $recommentList['users'];
    $totalNum           =   $recommentList['totalNum'];
    $totalPages         =   ceil($totalNum/$perpage);
    
    //条件恢复
    $orderbyArr		=	array($param['orderby']	 => " selected");
    $orderscArr 	=	array($param['ordersc']  => " selected");
    $perpageArr 	=	array($param['perpage']  => " selected");
    $uidArr 		=	array($param['uid']  	 => " selected");
    $levelArr		=	array($param['level1'],$param['level2']);
    $uidsArr		=	array($param['uid1'],  $param['uid2']);
    $diaryTimesArr		=	array($param['diaryTimes1'],	$param['diaryTimes2']);
    $likeTimesArr		=	array($param['likeTimes1'],		$param['likeTimes2']);
    $commentTimesArr	=	array($param['commentTimes1'],  $param['commentTimes2']);
    $commentTimesArr	=	array($param['commentMeTimes1'],  $param['commentMeTimes2']);
    $meFollowTimesArr	=	array($param['meFollowTimes1'], $param['meFollowTimes2']);
    $followMeTimesArr	=	array($param['followMeTimes1'], $param['followMeTimes2']);
    $topicTimesArr	    =	array($param['topicTimes1'], $param['topicTimes2']);
    $la_actTimesArr	    =	array($param['la_act1'], $param['la_act2']);
    
    // page
    $mpurl	   .= 	$urls;
    if ($page > 0){
        $mpurl	   .= 	$urls."&page=".$currtenPage;
    }
    $pageurl 	= 	multi($start, $perpage, $mpurl);
    $nextpurl 	= 	$pageurl['next'];
    $prevpurl 	= 	$pageurl['prev'];
    $mpurl 		= 	$pageurl['urls'];
    $firstpurl  = 	$pageurl['first'];
}






